package edu.kit.csl.cratylus.extraction.elki;

import de.lmu.ifi.dbs.elki.data.FeatureVector;
import de.lmu.ifi.dbs.elki.utilities.datastructures.arraylike.ArrayAdapter;
import edu.kit.csl.cratylus.datatypes.Candidate;

/**
 * This is a wrapper class for {@link Candidate} instances in order to make
 * the data suitable for ELKI. Therefore, this class has adapter functionality.
 * The dimensionality is fixed to 1, and the content is a {@link Candidate}
 * instance. 
 */
public class ElkiCandidate implements FeatureVector<ElkiCandidate, Candidate> {

	private Candidate candidate;
	
	/**
	 * Sole constructor.
	 * 
	 * @param candidate content
	 */
	public ElkiCandidate(Candidate candidate) {
		this.candidate = candidate;
	}

	/**
	 * The dimensionality is fixed to 1.
	 * {@inheritDoc}
	 */
	@Override
	public int getDimensionality() {
		return 1;
	}

	/**
	 * Get the candidate instance.
	 * 
	 * @return the candidate instance
	 */
	public Candidate getCandidate() {
		return candidate;
	}

	/**
	 * This function returns the candidate given in the constructor 
	 * unconditionally.
	 * {@inheritDoc}
	 */
	@Override
	public Candidate getValue(int dimension) {
		return candidate;
	}

	@Override
	public <A> ElkiCandidate newFeatureVector(A array,
			ArrayAdapter<Candidate, A> adapter) {
		return new ElkiCandidate(adapter.get(array, 0));
	}
}
